import Axios from './axios';
const API = {
    // 获取门前客流列表数据
    getFlowList: '/app/v1/saas/dailybusiness/gethumanflowlist',
    // 获取日商客流详情(废弃)
    getFlowDetail: '/app/v1/saas/dailybusiness/detail',
    // 获取日商客流详情-新增
    getAddForm: '/app/v1/saas/dailybusiness/getaddform',
    // 获取日商客流详情-编辑
    getModifiedForm: '/app/v1/saas/dailybusiness/getmodifiedform',
    // 保存日商客流
    saveModifiedForm: '/app/v1/saas/dailybusiness/save',
    // 日商统计 启用/停用
    flowSwitch: '/app/v1/saas/dailybusiness/switch',
    // 门前客流统计 启用/停用
    humanFlowSwitch: '/app/v1/saas/dailybusiness/humanflowswitch',
    // 店铺详情
    getShopDetail: '/app/v3/saas/app/collect/getdetail',
    // 项目详情
    getProjectDetail: '/app/v2/saas/app/project/detail',
    // 编辑投资测算
    investCalculationSave: '/app/v2/saas/app/project/investCalculationSave',
    // 提审
    checkProject: '/app/v1/saas/app/audit/apply',
    // Switch切换
    getBusinessDailyStats: '/app/v1/saas/dailybusiness/getbusinessdailystats'
};

const getFlowList = (params) => {
    return new Promise((resolve, reject) => {
        Axios.get(API.getFlowList, { params })
            .then((res) => {
                resolve(res.data.data);
            })
            .catch((e) => {
                reject(e);
            });
    });
};

const getFlowDetail = (params) => {
    return new Promise((resolve, reject) => {
        Axios.get(API.getFlowDetail, { params })
            .then((res) => {
                resolve(res.data.data);
            })
            .catch((e) => {
                reject(e);
            });
    });
};

const getAddForm = (params) => {
    return new Promise((resolve, reject) => {
        Axios.get(API.getAddForm, { params })
            .then((res) => {
                resolve(res.data.data);
            })
            .catch((e) => {
                reject(e);
            });
    });
};

const getModifiedForm = (params) => {
    return new Promise((resolve, reject) => {
        Axios.get(API.getModifiedForm, { params })
            .then((res) => {
                resolve(res.data.data);
            })
            .catch((e) => {
                reject(e);
            });
    });
};

const saveModifiedForm = (data) => {
    return new Promise((resolve, reject) => {
        Axios.post(API.saveModifiedForm, data)
            .then((res) => {
                resolve(res.data.data);
            })
            .catch((e) => {
                reject(e);
            });
    });
};

const flowSwitch = (data) => {
    return new Promise((resolve, reject) => {
        Axios.post(API.flowSwitch, data)
            .then((res) => {
                resolve(res.data.data);
            })
            .catch((e) => {
                reject(e);
            });
    });
};

const humanFlowSwitch = (data) => {
    return new Promise((resolve, reject) => {
        Axios.post(API.humanFlowSwitch, data)
            .then((res) => {
                resolve(res.data.data);
            })
            .catch((e) => {
                reject(e);
            });
    });
};

const getShopDetail = (params) => {
    return new Promise((resolve, reject) => {
        Axios.get(API.getShopDetail, { params })
            .then((res) => {
                resolve(res.data.data);
            })
            .catch((e) => {
                reject(e);
            });
    });
};

const getProjectDetail = (data) => {
    return new Promise((resolve, reject) => {
        Axios.post(API.getProjectDetail, data)
            .then((res) => {
                resolve(res.data.data);
            })
            .catch((e) => {
                reject(e);
            });
    });
};

const investCalculationSave = (data) => {
    return new Promise((resolve, reject) => {
        Axios.post(API.investCalculationSave, data)
            .then((res) => {
                resolve(res.data.data);
            })
            .catch((e) => {
                reject(e);
            });
    });
};

const checkProject = (data) => {
    return new Promise((resolve, reject) => {
        Axios.post(API.checkProject, data)
            .then((res) => {
                resolve(res.data.data);
            })
            .catch((e) => {
                reject(e);
            });
    });
};

const getBusinessDailyStats = (params) => {
    return new Promise((resolve, reject) => {
        Axios.get(API.getBusinessDailyStats, { params })
            .then((res) => {
                resolve(res.data.data);
            })
            .catch((e) => {
                reject(e);
            });
    });
};

export default {
    getFlowList,
    getFlowDetail,
    getAddForm,
    getModifiedForm,
    saveModifiedForm,
    flowSwitch,
    humanFlowSwitch,
    getShopDetail,
    getProjectDetail,
    investCalculationSave,
    checkProject,
    getBusinessDailyStats
};
